﻿Imports Microsoft.VisualBasic
Imports System.Data
Imports System.Data.SqlClient

Public Class BusquedasDB
    Public Shared Function GetBusquedas(ByVal id_vacante As Integer) As DataSet
        Dim cmd As New SqlCommand("spGetBusquedasVigentes", DB.Conexion)
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet

        If id_vacante = 0 Then
            cmd.Parameters.AddWithValue("@id_vacante", DBNull.Value)
        Else
            cmd.Parameters.AddWithValue("@id_vacante", id_vacante)
        End If

        cmd.CommandType = CommandType.StoredProcedure
        da.SelectCommand = cmd
        da.Fill(ds, "BusquedasVigentes")
        Return ds
    End Function

    Public Shared Function GetExperienciasBusquedaVigente(ByVal id_vacante As Integer) As DataSet
        Dim cmd As New SqlCommand("spGetExperienciasBusquedaVigente", DB.Conexion)
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet

        If id_vacante = 0 Then
            cmd.Parameters.AddWithValue("@id_vacante", DBNull.Value)
        Else
            cmd.Parameters.AddWithValue("@id_vacante", id_vacante)
        End If


        cmd.CommandType = CommandType.StoredProcedure
        da.SelectCommand = cmd
        da.Fill(ds, "ExperienciasBusquedaVigente")
        Return ds
    End Function

    Public Shared Function GetEstudiosBusquedaVigente(ByVal id_vacante As Integer) As DataSet
        Dim cmd As New SqlCommand("spGetEstudiosBusquedaVigente", DB.Conexion)
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet

        If id_vacante = 0 Then
            cmd.Parameters.AddWithValue("@id_vacante", DBNull.Value)
        Else
            cmd.Parameters.AddWithValue("@id_vacante", id_vacante)
        End If

        cmd.CommandType = CommandType.StoredProcedure
        da.SelectCommand = cmd
        da.Fill(ds, "EstudiosBusquedaVigente")
        Return ds
    End Function

    Public Shared Function GetPostulantesVacantes() As DataSet
        Dim cmd As New SqlCommand("spGetPostulantesVacantes", DB.Conexion)
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet

        cmd.CommandType = CommandType.StoredProcedure
        da.SelectCommand = cmd
        da.Fill(ds, "Postulaciones")
        Return ds
    End Function

End Class
